
import javax.swing.JTextArea;
import javax.swing.SwingWorker;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author jy
 */
public class MMExcute extends SwingWorker<String, Object> {
    private String m_str =null;
    private JTextArea m_jtx = null;
    private String m_result = " ";
    private long usedTime = 0;
    public MMExcute(){}
    
    public MMExcute(String str, JTextArea jtx)
    {
        m_str = str;
        m_jtx = jtx;
    }
    
    @Override
    protected String doInBackground()
    {
        long startTime = System.currentTimeMillis();
        MaxMatching mm = new MaxMatching(3);
        mm.maxMatching(m_str);
        
        long endTime = System.currentTimeMillis();
        setUsedTime(endTime - startTime);
        
        return mm.getResult();
    }
    
    protected void done()
    {
        try{
            m_jtx.setText(get());
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
    private void setUsedTime(long used)
    {
        usedTime = used;
    }
    
    public long getUsedTime()
    {
        return usedTime;
    }
}
